<template>
  <div id="main" class="echarts"></div>
</template>

<script>
import * as echarts from 'echarts';
export default {
  props:{
    chartslist:{
      type:Array,
      default:()=>[]
    }
  },
  name: 'EchartsData',
  data() {
    return {

    }
  },
  methods: {
    init() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('main'));
      // 绘制图表
      myChart.setOption({
        title: {
          text: '碳足迹计算器可视化图表',
          subtext: '桂林电子科技大学',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '产生co2',
            type: 'pie',
            radius: '50%',
            data: this.chartslist,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      });
    }
  },
  mounted() {
    this.init()
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
